package com.king.designpatterns.行为模式.责任链模式;

/**
 * 抽象类 - 传花者
 *
 * @author king
 * @date 2021-06-10 15:50
 */
public abstract class Player {
    private Player successor;

    public abstract void handle(int i);

    protected void setSuccessor(Player successor) {
        this.successor = successor;
    }

    /**
     * 传给下一个
     *
     * @param index 下一位传花者
     */
    public void next(int index) {
        if (null != successor) {
            successor.handle(index);
        } else {
            System.out.println("游戏结束");
        }
    }
}
